<div class="referee-url">
    您的专属推广链接：<button class="copy" data-clipboard-target="">复制</button> <button class="see">查看代理规则</button>
    <div class="url">
    </div>
</div>

<div class="filter-content">
    <div class="filter">
        <div class="f">
            请选择统计日期：
        </div>
        <div class="f f2 item" style="width: 120px;">
            <input type="text" class="am-form-field" placeholder="起始日期" id="start"
                data-am-datepicker="{theme:'success'}" readonly required />
        </div>
        <div class="f f3 item" style="width: 120px;">
            <input type="text" class="am-form-field" placeholder="结束日期" id="end"
                data-am-datepicker="{theme:'success'}" readonly required />
        </div>

        <div class="f f16 item" style="width: 150px;">
            <select data-am-selected>
            </select>
        </div>
    </div>
</div>

<div style="margin:10px 10px 5px 10px;">
<table class="am-table am-table-striped am-table-hover center-table daili-table" style="border-bottom: 1px solid #ccc;">
  <thead>
  <tr>
    <th width="120px">账号名</th>
    <th width="120px">姓名</th>
    <th width="80px">奖励金额</th>
    <th width="90px">惩罚金额</th>
    <th width="80px">投注金额</th>
    <th width="120px">输赢(不含返水)</th>
    <th width="80px">返水</th>
    <th width="80px">实际输赢</th>
  </tr>
  </thead>
  <tbody>
      <tr>
          <td colspan="8">没有任何数据！</td>
      </tr>
  </tbody>
</table>
</div>

<div class="summary">
    共<span class="red total">0</span>条记录，每页<span class="red pageSize"></span>条。
</div>
<div class="zxf_pagediv"></div>

<style type="text/css">
    .sum {
        float: right;
        width: 200px;
        color: black;
        font-size: 16px;
        margin-bottom: 10px;
    }
    
    .referee-url {
        padding: 15px;
    }
    .referee-url .url {
        border: 1px solid #ccc;
        margin-top: 15px;
        text-align: center;
        background-color: #ffd101;
        line-height: 34px;
        border-radius: 6px;
        color: #000;
    }
</style>

<script src="../public/all/js/clipboard.min.js"></script>
<script src="../public/all/js/page_list.js"></script>
<script>
    ME.query(function() {
        $(".referee-url .url").html(context.config.url + "pc/index.html?referee=" + (context.user.user.mobile || ''));
    });

    var pl = new PageList();
    pl.fillPageSelect($(".f16 select"));

    var clipboard = new Clipboard('.referee-url .copy', {
        text: function() {
            return $(".referee-url .url").html();
        },
    });
    clipboard.on("success", function(e) {
        alert2("复制成功！您可以分享到微信、QQ、新浪微博等！");
    });

    var _query = function(page) {
        page = page || 1;
        var start = $(".f2 input").val();
        var end = $(".f3 input").val();
        CMD.stat_user_referee(undefined, undefined, start, end, undefined, undefined, pl.getPageSize(), page, function(r) {
            pl.fillPages(r.count, r.number, r.page, r.size);
            fillResults(r.list);
        });
    };
    pl.jumpUrl = _query;
    _query(1);

    function fillResults(list) {
        var table = $(".daili-table tbody");
        table.empty();
        if (list.length == 0) {
            table.append("<tr><td colspan='8'>没有任何数据！</td></tr>");
            return;
        }
        
        for (var i in list) {
            var tr = $("<tr></tr>");
            var d = list[i];
            var user = d.user;

            tr.append("<td>" + (user.mobile || '') + "</td>");
            tr.append("<td>" + (user.name || '') + "</td>");
            tr.append("<td>" + ((d.rewardSum || 0)/100).toFixed(2) + "</td>");
            tr.append("<td>" + ((d.depositSum || 0)/100).toFixed(2) + "</td>");
            tr.append("<td>" + ((d.betSum || 0)/100).toFixed(2) + "</td>");
            tr.append("<td>" + ((d.betProfit || 0)/100).toFixed(2) + "</td>");
            tr.append("<td>" + ((d.backSum || 0)/100).toFixed(2) + "</td>");
            var win = (d.betProfit || 0) + (d.backSum || 0);
            tr.append("<td>" + ((win || 0)/100).toFixed(2) + "</td>");

            table.append(tr);
        }
    }

</script>